<script setup>
import { ref } from 'vue'
const userPwd = ref({
    old_pwd: '',
    new_pwd: '',
    re_pwd: '',
})
const rules = {
    new_pwd: [
        { required: true, message: "请输入密码", trigger: "blur" },
        { min: 5, max: 16, message: "长度必须为5-16位", trigger: "blur" },
    ],
    re_pwd: [
        { required: true, message: "请输入密码", trigger: "blur" },
        { min: 5, max: 16, message: "长度必须为5-16位", trigger: "blur" },
    ],
}

import { userPwdUpdateService } from '@/api/user'
import { ElMessage } from 'element-plus';

const updatePwd = async () => {
    let result = await userPwdUpdateService(userPwd.value);
    console.log(userPwd.value);
    ElMessage.success(result.msg ? result.msg : '修改成功')
}


</script>
<template>
    <el-card class="page-container">
        <template #header>
            <div class="header">
                <span>重置密码</span>
            </div>
        </template>
        <el-row>
            <el-col :span="12">
                <el-form :model="userPwd" :rules="rules" label-width="100px" size="large">
                    <el-form-item label="原密码" >
                        <el-input v-model="userPwd.old_pwd"></el-input>
                    </el-form-item>
                    <el-form-item label="新密码" prop="new_pwd">
                        <el-input v-model="userPwd.new_pwd"></el-input>
                    </el-form-item>
                    <el-form-item label="重复新密码" prop="re_pwd">
                        <el-input v-model="userPwd.re_pwd"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="updatePwd">提交修改</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </el-card>
</template>